/**
 * Project Name:Bee
 * File Name:PopupAdapter.java
 * Package Name:com.longcai.p2p.bee.adapter
 * Date:2015-10-26上午10:09:45
 * Copyright (c) 2015, chenzhou1025@126.com All Rights Reserved.
 *
*/

package com.lc.user.express.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lc.user.express.R;
import com.lc.user.express.app.AppContext;
import com.lc.user.express.model.BankModel;

import java.util.List;

/**
 * @ClassName:PopupAdapter
 * @Function: TODO 
 * @Date:     2015-10-26 上午10:09:45
 * @author   Administrator
 * @version  
 * @since    JDK 1.6	 
 */
public class PopupAdapter extends BaseListAdapter<BankModel>{

    private int type;
    public PopupAdapter(Context context, List<BankModel> data, int type) {
        
        super(context, data);
        // TODO Auto-generated constructor stub
        this.type = type;
        
    }

    @Override
    public View getView(int arg0, View arg1, ViewGroup arg2) {

        ViewHolder viewHolder = null;
        // TODO Auto-generated method stub
        if(arg1 ==null){
            arg1 = LayoutInflater.from(mContext).inflate(R.layout.item_popup_bank, null);
            AppContext.ScaleScreenHelper.loadView((ViewGroup) arg1);
            viewHolder = new ViewHolder();
            viewHolder.tv_title = (TextView)arg1.findViewById(R.id.tv_title);
            viewHolder.iv_pic = (ImageView)arg1.findViewById(R.id.iv_pic);
            viewHolder.iv_ok = (ImageView)arg1.findViewById(R.id.iv_ok);
            arg1.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder)arg1.getTag();
        }

        if(type ==1){
            viewHolder.tv_title.setText(data.get(arg0).getName());
            viewHolder.tv_title.setVisibility(View.VISIBLE);
            viewHolder.iv_pic.setVisibility(View.GONE);
        }else{
//            ImageManager.from(mContext).displayImage(viewHolder.iv_pic, UrlApi.SERVER_URL+data.get(arg0).getPic(),R.drawable.shape_background);
            viewHolder.tv_title.setVisibility(View.GONE);
            viewHolder.iv_pic.setVisibility(View.VISIBLE);
        }


        if(data.get(arg0).isChoosed()){
            viewHolder.iv_ok.setVisibility(View.VISIBLE);
        }else {
            viewHolder.iv_ok.setVisibility(View.GONE);
        }
        return arg1;
    }
    class ViewHolder{
        TextView tv_title;
        ImageView iv_pic;
        ImageView iv_ok;
    }
}

